<script src="<?php print $url?>js/data-table.jquery.js"></script>
<script>
  $(function () {
    $('.data-tbl-boxy').dataTable({
        "sPaginationType": "full_numbers",
        "iDisplayLength": 10,
        "oLanguage": {
            "sLengthMenu": "<span class='lenghtMenu'> _MENU_</span><span class='lengthLabel'>Entries per page:</span>",
        },
        "sDom": '<"tbl-searchbox clearfix"fl<"clear">>,<"table_content"t>,<"widget-bottom"p<"clear">>'

    });
  });
</script>
<div id="main-content">
  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span12">
        <div class="widget-block">
          <?php
          if($message == 'filed'){
          ?>
          <div class="alert alert-error fade in">
            <button data-dismiss="alert" class="close" type="button">×</button>
            <strong>Failed!</strong> Fail to save data.
          </div>
          <?php
          }
          if($message == 'sukses'){
          ?>
          <div class="alert alert-success fade in">
            <button data-dismiss="alert" class="close" type="button">×</button>
            <strong>Success!</strong> Now you have new user.
          </div>
          <?php
          }
          ?>
          <div class="widget-head">
            <h5>Users Data Table</h5>
            <div class="widget-control pull-right">
              <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="<?php print   site_url("users/add-new") ?>"><i class="icon-plus"></i> Add New</a></li>
              </ul>
            </div>
          </div>
          <div class="widget-content">
            <div class="widget-box">
              <table class="data-tbl-boxy table">
                <thead>
                  <tr>
                    <th>Name</th>
                    <th>Privilege</th>
                    <th>Email</th>
                    <th>Status</th>
                    <th>Option</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  if(is_array($data)){
                    foreach ($data as $key => $value) {
                      if($value->id_status_user == 1)
                        $status = "<span class='label label-success'>Active</span>";
                      else
                        $status = "<span class='label label-important'>Not Active</span>";
                        
                      $link_edit = site_url("users/add-new/".$value->id_users);
                      $link_delete = site_url("users/delete/".$value->id_users);
                      $link_status = site_url("users/status/".$value->id_users."/$value->id_status_user");
                      $link_pass = site_url("users/generate-password/".$value->id_users);
                      $link_email_pass = site_url("users/email-pass/".$value->id_users);
                      print <<<EOD
                  <tr>
                    <td>{$value->name}</td>                     
                    <td>{$value->privilege}</td>
                    <td>{$value->email}</td>
                    <td>{$status}</td>
                    <td>
                      <div class="btn-group">
                        <button data-toggle="dropdown" class="btn btn-small dropdown-toggle">Action<span class="caret"></span></button>
                        <ul class="dropdown-menu">
                          <li><a href="{$link_status}">Change Status</a></li>
                          <li><a href="{$link_edit}">Edit</a></li>
                          <li><a href="{$link_delete}">Delete</a></li>
                          <li><a href="{$link_pass}">Generate Password</a></li>
                          <li><a href="{$link_email_pass}">Email Password</a></li>
                        </ul>
                      </div>
                    </td>     
                  </tr>
EOD;
                    }
                  }
                  ?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>